home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 27 / CDROM27.iso / share / progra / mai / Drives, finding the CD-ROM on a system < prev    next >
Encoding:
Text File  |  1997-07-13  |  1.3 KB  |  35 lines

  1. 'Description: Detects the drive letter associated with the CD - ROM Drive.
  2.  
  3. 'Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
  4. 'Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
  5. 'Private Const DRIVE_REMOVABLE = 2
  6. 'Private Const DRIVE_FIXED = 3
  7. 'Private Const DRIVE_REMOTE = 4
  8. 'Private Const DRIVE_CDROM = 5
  9. 'Private Const DRIVE_RAMDISK = 6
  10.  
  11.  
  12. 'Place the following code in under a command button or in a menu, etc...
  13.  
  14. Dim r&, allDrives$, JustOneDrive$, pos%, DriveType&
  15. Dim CDfound As Integer
  16. allDrives$ = Space$(64)
  17. r& = GetLogicalDriveStrings(Len(allDrives$), allDrives$)
  18. allDrives$ = Left$(allDrives$, r&)
  19. Do
  20. pos% = InStr(allDrives$, Chr$(0))
  21. If pos% Then
  22.         JustOneDrive$ = Left$(allDrives$, pos%)
  23.         allDrives$ = Mid$(allDrives$, pos% + 1, Len(allDrives$))
  24.         DriveType& = GetDriveType(JustOneDrive$)
  25.         If DriveType& = DRIVE_CDROM Then
  26.            CDfound% = True
  27.            Exit Do
  28.         End If
  29.       End If
  30.   Loop Until allDrives$ = "" Or DriveType& = DRIVE_CDROM
  31.   If CDfound% Then
  32.         label1 = "The CD-ROM drive on your system is drive " & UCase$(JustOneDrive$)
  33.   Else: label1 = "No CD-ROM drives were detected on your system."
  34.   End If
  35.